package com.example.openim.controller;

import com.example.openim.domain.GroupReviewInfo;
import com.example.openim.dto.BatchReadDto;
import com.example.openim.dto.GroupInfoDto;
import com.example.openim.service.GroupInfoService;
import com.example.openim.utils.AjaxResult;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @description: 群组
 * @author: xhq
 * @create: 2025-11-06 16:44
 */
@Slf4j
@RequestMapping("/api/group")
@RestController
public class GroupInfoController {

    @Autowired
    private GroupInfoService groupInfoService;


    /**
     * 创建群组添加群组审核信息
     *
     * @param dto
     * @return
     */
    @PostMapping("/createGroup")
    public AjaxResult createGroup(@RequestBody GroupInfoDto dto) {
        return groupInfoService.createGroup(dto);
    }

    @GetMapping("/queryList")
    public AjaxResult queryList(String creatorUserID,Integer page,Integer pageSize) {
        return AjaxResult.success(groupInfoService.queryList(creatorUserID,page,pageSize));
    }


    @PostMapping("/audit")
    public AjaxResult audit(HttpServletRequest httpServletRequest, @RequestBody GroupReviewInfo dto) {
        return this.groupInfoService.audit(httpServletRequest, dto);
    }

    /**
     * 批量已读
     *
     * @param dto
     * @return
     */
    @PostMapping("/batchRead")
    public AjaxResult batchRead(@RequestBody BatchReadDto dto) {
        return this.groupInfoService.batchRead(dto);
    }

}
